import $ from "jquery";
import {url} from "../../util/config";
import {message} from "antd";
import login from "../login";
function getNewLogin(searchKey=null,personNum=null,startDate=null,endDate=null,current=null,pageSize=null) {
    return getNoticeLog(searchKey,personNum,startDate,endDate,current,pageSize)
}
export default function getNoticeLog(searchKey=null,personNum=null,startDate=null,endDate=null,current=null,pageSize=null){
    let token = localStorage.getItem("token")
    let status = {
        count:null,
        data:null
    };
    $.ajax({
        async:false,
        headers: {
            'Accept': "application/json",
            'Authorization': token
        },
        url: url.api_url+`Log/getNoticeLog?searchKey=${searchKey}&personNum=${personNum}&startDate=${startDate}&endDate=${endDate}&current=${current}&pageSize=${pageSize}`,
        type: 'get',
        contentType:"application/json",
        success: function (result) {
            if(result.result=="Token過期請重新登錄"){
                login(localStorage.getItem("account"), localStorage.getItem("password"));
                status = getNewLogin(searchKey,personNum,startDate,endDate,current,pageSize)
            }else {
                console.log("getDatasForMove:",result)
                //no permission 、error 或者 正常的數組數據
                status.data = result.result
                status.count = result.count
            }
        },
        error:function (error) {
            message.error("请求异常");
            status.data = "error"
        }
    })
    return status;
}
